import { Directive, Input, ElementRef, OnInit } from '@angular/core';

/**
 * Generated class for the RequiredDirective directive.
 *
 * See https://angular.io/api/core/Directive for more info on Angular
 * Directives.
 */
@Directive({
    selector: '[required]' // Attribute selector
})
export class RequiredDirective implements OnInit {

    @Input('required')
    requiredValue: string;

    constructor(private el: ElementRef) {
    }

    ngOnInit() {
        if (this.requiredValue) {
            const span = document.createElement('span');
            span.innerHTML = '*';
            span.style.color = '#f00';
            this.el.nativeElement.appendChild(span);
        }
    }
}
